package pools;

import tree.Node;
import tree.TreeNodesManager;
import Factory.BooleanNodesFactory;
import Factory.ConstantFactory;
import Factory.NumericNodesFactory;

public class PoolsManager {

	private NumericNodesFactory numericFactory;
	private BooleanNodesFactory booleanFactory;
	private ConstantFactory constFactory;
	
	//----Singleton implementation---//
	public static class PoolsManagerHolder{
		private final static PoolsManager poolsManager=new PoolsManager();  
	}
	
	public static PoolsManager get(){
		return PoolsManagerHolder.poolsManager;
	}
	
	private PoolsManager() {
		numericFactory=new NumericNodesFactory();
		booleanFactory=new BooleanNodesFactory();
		constFactory=new ConstantFactory();
	}
	
	public Node getRandomBooleanNode(int depth, int maxDepth, Node parent, TreeNodesManager treeNodesManager){
		return booleanFactory.createRandomNode(parent, depth, maxDepth,treeNodesManager);
	}
	
	public Node getRandomNumericFuncNode(int depth, int maxDepth, Node parent,TreeNodesManager treeNodesManager){
		return numericFactory.createRandomNode(parent, depth, maxDepth,treeNodesManager);
	}
	
	public Node getRandomConstantNode(Node parent, TreeNodesManager treeNodesManager,int depth) {		
		return constFactory.createRandomNode(parent,treeNodesManager,depth);
	}
	
	public Node getRandomBooleanWithBooleanSonsNode(int depth, int maxDepth
													,Node parent,TreeNodesManager treeNodesManager){
		return booleanFactory.createRandomBooleanSonsNode(parent, depth, maxDepth, treeNodesManager);
	}
	
	public Node getRandomBooleanWithNumericSonsNode(int depth, int maxDepth
													, Node parent,TreeNodesManager treeNodesManager){
		return booleanFactory.createRandomNumericSonsNode(parent, depth, maxDepth, treeNodesManager);
	}	
	
}
